<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <!-- Set render engine for 360 browser -->
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- HTML5 shim for IE8 support of HTML5 elements -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <![endif]-->


    <link href="__STATIC__/flatadmin/bootstrap.min.css" rel="stylesheet">
    <link href="__STATIC__/flatadmin/simplebootadmin.css" rel="stylesheet">
    <link href="__STATIC__/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">

    <!--[if lt IE 9]>
    <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    
    <script type="text/javascript">
        //全局变量
        var GV = {
            ROOT: "__ROOT__/",
            WEB_ROOT: "__WEB_ROOT__/",
            JS_ROOT: "static/js/",
            APP: '{$Request.module}'/*当前应用名*/
        };
    </script>
    <script src="__STATIC__/js/jquery.js"></script>
    <script src="__STATIC__/js/wind.js"></script>
    <script>
        Wind.css('artDialog');
        Wind.css('layer');
        $(function () {
            $("[data-toggle='tooltip']").tooltip();
            $("li.dropdown").hover(function () {
                $(this).addClass("open");
            }, function () {
                $(this).removeClass("open");
            });
        });
    </script>

<title>课堂资料</title>
<style>
.list-boxes {
    overflow: hidden;
    padding: 15px 20px;
    margin-bottom:25px;
    background: #fff;
    -webkit-transition: all 0.3s ease-in-out;
    -moz-transition: all 0.3s ease-in-out;
    -o-transition: all 0.3s ease-in-out;
    transition: all 0.3s ease-in-out;
    word-wrap: break-word;
    word-break: break-all;
    border: solid 1px #eee;
}
</style>
<style>
.badge-warning{
	font-size:14px;
	background-color:#95a5a6;
	padding:7px 12px;
	margin:3px;
	cursor:pointer;
}
.badge-selected{
	background-color:#fa3;
}
/*header*/
.header{ height:44px; background:#4eabe8;position: relative;z-index: 10;}
.new-a-back {left: 6px;position: absolute;top: 13px;}
.new-a-back span { display:block;height: 18px;text-indent:17px; line-height:18px;width: 45px; color:#FFF; font-size:14px;}
.header h2 {color: #fff;font-size: 16px;font-weight: normal;height: 44px;line-height: 44px; text-align: center; font-weight:bold;}
.new-a-jd { height: 30px;position: absolute; right: 7px;top: 6px; width: 37px;}
.new-a-jd span {background: url("../images/icon2b.png") no-repeat -125px -24px / 180px 180px;display: inline-block; height: 21px;margin: 5px 0 0 8px;text-indent: -9999px;width: 21px;}
body,h1,h2,h3,h4,h5,h6{margin:0;padding:0;}
</style>
</head>
<script src="__STATIC__/js/bootstrap.min.js"></script>
<body>
<!--header 开始-->
<if condition="cmf_get_current_admin_id()">
  <header style="width:100%;margin-top:0px;">
    <div class="header" style="width:100%;"> 
		<a class="new-a-back" href="{:url('portal/wx_admin/tools')}"><span style="text-indent:0px;"><返回</span></a>
		<h2>课堂资料<a style="margin-left:5px;font-size:10px;color:#fff;" href="{:url('portal/wx_admin/select_class')}">{$this_timetable_data['class_name']}<i class="fa fa-chevron-down"></i></a></h2>
		<!-- <a class="new-a-jd" id="trigger-overlay" href="javascript:void(0)"> <span>导航菜单</span> </a> -->
    </div>
  </header>
</if>
  <!--header 结束-->
<div class="container">
    <if condition="!cmf_get_current_admin_id()"><h2>{$this_timetable_data['class_name']}-课堂资料</h2></if>
	<div class="btn-group" style="margin:15px 0;">
		<button class="btn btn-default" style="height:34px;">{$this_timetable_data['times']?'第'.$this_timetable_data['times'].'次课':'全部'}</button> <button data-toggle="dropdown" class="btn btn-default dropdown-toggle" style="height:34px;margin-right:5px;"><span class="caret"></span></button>
		<ul class="dropdown-menu">
			<li><a href="{:url('portal/article/blog',['class_id'=>$this_timetable_data['class_id']])}">全部</a></li>
			<foreach name="class_timetable_list" item="times_vo">
				<li><a href="{:url('portal/article/blog',['timetable_id'=>$times_vo['id']])}">第{$times_vo['times']}次课</a></li>
			</foreach>
		</ul>
		<foreach name="tags_data" item="tags_data_vo">
			<php>$url_param = $param;unset($url_param['tags']);</php>
			<a href="{:url('portal/article/blog',$url_param,'',true)}{:isset($param['tags'])&&$param['tags']==$tags_data_vo['id']?'':'/tags/'.$tags_data_vo['id']}"><span onclick='javascript:;' class="badge badge-warning {:isset($param['tags'])&&$param['tags']==$tags_data_vo['id']?'badge-selected':''}">{$tags_data_vo['name']}</span></a>
		</foreach>
	</div>
    <div class="row">
        <div class="col-md-12">
			<foreach name="blog_data" item="vo">
				<div class="list-boxes">
					<h3>{$vo['title']} {$vo['is_top']==1?'<span style="color:red;">[置顶]</span>':''}</h3>
					<p>{$vo['user_nickname']}最后编辑于{:date("Y-m-d H:i:s",$vo['update_time'])}</p>
					<div id="article_content" style="margin-top:20px;">
						{$vo['content']|default=''}
					</div>
					<ul class="pic-list list-unstyled form-inline">
						<if condition="isset($vo['more']['photos'])">
						<foreach name="$vo['more']['photos']" item="photo_vo" key="photo_key">
							<li>
								<a href="/upload/{$photo_vo['url']}" style="font-size:16px;" download>
									<li class="fa fa-paperclip normal" style="font-size:16px;"></li>
									<span>{$photo_vo['name']}</span>
								</a>
								<img src="{:cmf_get_image_url($photo_vo['url'])}" style="height:36px;margin-left:10px;" onclick="javascript:img_view(this.src);">
							</li>
						</foreach>
						</if>
					</ul>
					<ul class="pic-list list-unstyled form-inline">
						<if condition="isset($vo['more']['files'])">
						<foreach name="$vo['more']['files']" item="file_vo" key="file_key">
							 <li>
								<a href="/upload/{$file_vo['url']}" style="font-size:16px;">
									<li class="fa fa-paperclip normal" style="font-size:16px;"></li>
									<span>{$file_vo['name']}</span>
								</a>							
							</li>
						</foreach>
						</if>
					</ul>
					<div>
						<div class="pull-left">
							<div class="list-actions">
								<a href="javascript:;"><i class="fa fa-eye"></i><span>{$vo['post_hits']+1}</span></a>
								<!-- <a href="{:url('portal/Article/doLike')}" class="js-count-btn"><i class="fa fa-thumbs-up"></i><span class="count">12</span></a> -->
								<!-- <a href="{:url('user/Favorite/add')}" class="js-favorite-btn"><i class="fa fa-star-o">13</i></a> -->								
							</div>
						</div>
					</div>
				</div>
			</foreach>
			<p id="load_more" style="text-align:center;">点击加载更多……</p>
        </div>
    </div>

</div>

</body>

<script>
$(function(){
    $(window).scroll(function(){
		load_more();
	});
	$("#load_more").click(function(){
		load_more();
	});
});
var page = 2;
var lock = true;
function load_more(){
		var window_height = $(window).height();
		var document_height = $(document).height();
		var scroll_top = $(window).scrollTop();
		var need_data = document_height-window_height-scroll_top;

		if(need_data<200&&lock){
			lock = false;
			var url = "{:url('portal/article/blog',$param,'',true)}";
			$.ajax({
				url: url+'/page/'+page,
				type: 'post',
				success: function (e) {
					if(e['data'].length>0){
						page++;
						lock = true;
						var html_context= '';
						for(var i = 0;i<e['data'].length;i++){
							html_context += "<div class='list-boxes'><h3>"+e['data'][i]['title']+"</h3><p>"+e['data'][i]['user_nickname']+"最后编辑于"+e['data'][i]['update_time']+"</p><div id='article_content' style='margin-top:20px;'>"+e['data'][i]['content']+"</div><div>";
							if(e['data'][i]['more']!=undefined&&e['data'][i]['more']!=null){
								if(e['data'][i]['more']['photos']!=undefined&&e['data'][i]['more']['photos'].length>0){
									html_context += '<ul class="pic-list list-unstyled form-inline">';
									for(var photos_key = 0;photos_key<e['data'][i]['more']['photos'].length;photos_key++){
										html_context += '<li><a href="/upload/'+e['data'][i]['more']['photos'][photos_key]['url']+'" style="font-size:16px;" download><li class="fa fa-paperclip normal" style="font-size:16px;"></li><span>'+e['data'][i]['more']['photos'][photos_key]['name']+'</span></a><img src="/upload/'+e['data'][i]['more']['photos'][photos_key]['url']+'" style="height:36px;margin-left:10px;" onclick="img_view(this.src);"></li>';
									}
									html_context += '</ul>';
								}
								if(e['data'][i]['more']['files']!=undefined&&e['data'][i]['more']['files'].length>0){
									html_context += '<ul class="pic-list list-unstyled form-inline">';
									for(var photos_key = 0;photos_key<e['data'][i]['more']['files'].length;photos_key++){
										html_context += '<li><a href="/upload/'+e['data'][i]['more']['files'][photos_key]['url']+'" style="font-size:16px;"><li class="fa fa-paperclip normal" style="font-size:16px;"></li><span>'+e['data'][i]['more']['files'][photos_key]['name']+'</span></a></li>';
									}
									html_context += '</ul>';
								}
							}
							html_context += "<div class='pull-left'><div class='list-actions'><a href='javascript:;'><i class='fa fa-eye'></i><span>"+e['data'][i]['post_hits']+"</span></a></div></div></div></div>";
						}
						$(".list-boxes:last").after(html_context);
					}
					else{
						$("#load_more").html('<p id="load_more" style="text-align:center;">没有更多资料了！</p>');
					}
				}
			});
		}
	}
</script>
<script>
function img_view(img){
	if (self.frameElement && self.frameElement.tagName == "IFRAME") {
	　　window.parent.imagePreviewDialog(img);
	}
	else{
		imagePreviewDialog(img);
	}
}

function imagePreviewDialog(img) {
    Wind.css('layer');

    Wind.use("layer", function () {
        layer.photos({
            photos: {
                "title": "", //相册标题
                "id": 'image_preview', //相册id
                "start": 0, //初始显示的图片序号，默认0
                "data": [   //相册包含的图片，数组格式
                    {
                        "alt": "",
                        "pid": 666, //图片id
                        "src": img, //原图地址
                        "thumb": img //缩略图地址
                    }
                ]
            } //格式见API文档手册页
            , anim: 5, //0-6的选择，指定弹出图片动画类型，默认随机
            shadeClose: true,
            // skin: 'layui-layer-nobg',
            shade: [0.5, '#000000'],
            shadeClose: true,
        })
    });
}
</script>
</html>